package com.siteseat.common.foundation;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class SchedulerThreadFactory implements ThreadFactory {
  
  private ThreadFactory DELEGATED = Executors.defaultThreadFactory();
  
  private String name;
  
  private int sequence;
  
  /**
   * 
   *
   *
   * @param name
   */
  public SchedulerThreadFactory( String name ) {
    this.name = name;
  }
  
  /**
   * {@inheritDoc}
   */
  @Override
  public Thread newThread( Runnable r ) {
    Thread t = DELEGATED.newThread( r );
    t.setName( this.name + (++sequence) );
    return t;
  }

}
